package handlers

import (
	"github.com/gin-gonic/gin"
	"repo-nav/model"
)

func Add(c *gin.Context) {
	name := c.PostForm("name")
	address := c.PostForm("address")

	data := model.Repo{
		Name:    name,
		Address: address,
	}
	model.DB.Create(&data)
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "添加成功",
		"data": data,
	})
	return
}
func List(c *gin.Context) {
	var repo []model.Repo
	model.DB.Find(&repo)

	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "查询成功",
		"data": repo,
	})
	return
}
